Skip to content
This repository has been archived by the owner on Apr 16, 2021. It is now read-only.

Backport patches from arduino/ArduinoCore-mbed #81

Merged
merged 20 commits into from
Jul 14, 2020
Merged

Backport patches from arduino/ArduinoCore-mbed #81

merged 20 commits into from
Jul 14, 2020

Conversation

facchinm
Copy link
Member

@facchinm facchinm commented Jun 11, 2020

This should be the last maintenance release of this core; since this core is based on mbed 5.x branch all functions marked for deprecation are still there; arduino/ArduinoCore-mbed, on the other hand, contains all the new stuff and should replace this core as soon as considered stable.

Reworks and includes #31 and #72

facchinm and others added 17 commits June 11, 2020 12:41
A Nordic specific ADC configuration is implemented in 'variant.cpp'.
It can be modified using 'analogReference' function, all the reference
options are defined in 'pins_arduino.h'.
Once the configuration is changed:
- the already active ADC objects are reconfigured.
- new ADC objects will be set to the most recent configuration.
Implement a Nordic specific function able to change the acquisition time
of ADCs.
- PinMode is redefined to be compatible with both Arduino and Mbed contexts
- DigitalInOut is employed to handle gpio, it now exploits the
reconfigure PinMode symbol
Implements checks on DigitalRead and DigitalWrite functions. If the requested pin is not
initialized, it is assigned to a new DigitalInOut object configured as:
- if INPUT: no pull and 0 as default value
- if OUTPUT: no pull and the argument value as init value
@rmlearney-digicatapult
Copy link
Contributor

Excited!

One note - interrupts.cpp still doesn't cover all possible interrupt types (HIGH, LOW) - is it better to have the irq setting as a switch(mode) rather than nested if/else tests so it can be extended in future?

@facchinm
Copy link
Member Author

facchinm commented Jun 11, 2020

Ah sorry, I just spotted an error in my last rebase; working on it now
@rmlearney-digicatapult I misread your comment 🙂
mbed doesn't currently support level based interrupts https://github.com/arduino/ArduinoCore-nRF528x-mbedos/blob/beta/cores/arduino/mbed/hal/gpio_irq_api.h#L34-L38 but we can work on it with them. If you could open a separate issue it could be better to keep track of the request

@rmlearney-digicatapult
Copy link
Contributor

rmlearney-digicatapult commented Jun 11, 2020

@facchinm ah, if they're not supported then no worries. Thanks!

@rmlearney-digicatapult
Copy link
Contributor

rmlearney-digicatapult commented Jun 16, 2020

@facchinm this implementation in Interrupts.cpp doesn't seem to support CHANGE:

  // Give a default pullup for the pin, since calling InterruptIn with PinMode is impossible
   if (digitalPinToGpio(interruptNum) == NULL) {
     pinMode(interruptNum, mode == FALLING ? INPUT_PULLUP : INPUT_PULLDOWN);
   }

Perhaps the following?

   if (digitalPinToGpio(interruptNum) == NULL) {
     switch(mode){
       case FALLING:
         pinMode(interruptNum, INPUT_PULLUP);
         break;
       case RISING:
         pinMode(interruptNum, INPUT_PULLDOWN);
         break;
       case CHANGE:
         pinMode(interruptNum, INPUT);
         break;
       default:
         pinMode(interruptNum, INPUT);
         break;
     }
   }

@facchinm
Copy link
Member Author

@rmlearney-digicatapult the snippet you are linking only applies is the pin has not been configured as INPUT before calling attachInterrupt . If you look at the beta branch, the implementation on CHANGE is correct https://github.com/arduino/ArduinoCore-nRF528x-mbedos/blob/beta/cores/arduino/Interrupts.cpp#L39-L48

@rmlearney-digicatapult
Copy link
Contributor

rmlearney-digicatapult commented Jun 17, 2020

What will be the default pin state if somebody doesn't configure the pin as INPUT but calls an attachInterrupt on CHANGE?

Won't it be pulled down according to this code, which means it won't trigger properly?

@facchinm
Copy link
Member Author

Yep, you are right! Would you mind sending a PR over beta branch with the commit to fix it (so we can keep the attribution) ? Thanks

rmlearney-digicatapult and others added 3 commits June 19, 2020 09:20
Works in sync with upcoming arduino-builder for precompiled libraries
Borrow implementation for samd core
Should fix #85
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants